|
LotusScript library: LSALibFct
|
| Global variables |
Private ThisMsg = LSAMessage
Private PatternS List = Pattern
Private PatternSUb = Integer
|
Provides a set of basic functions similar to functions available in @Language. Examples are VLeft, VImplode
VTrim or alike. These start with V as they are designed to take variants as a parameter which may be both
strings and arrays. They also use EMPTY as input or in some cases as return value rather than "".
For example VTrim returns an EMPTY if there is no non space element in the input.
Requires the messagehandler LSALibMsgH.
-
Author:
-
LPS EMEA
-
Version:
-
2.0.1, 06JUN.2000
-
History:
-
| 29.MAR.2000 | ESc | Reworked for docu standards
|
| 02.MAY.2000 | ESc | Parse CGI case insensitive and handles %20 as blank.
|
| 02.MAY.2000 | ESc | added VEqual a routine to compare arrays on equality.
|
| 06.JUN.2000 | ESc | set necessary auxilaty routines and variables to private.
|
| 19.JUL.2000 | ESc | errprepare text fkt->fct, hint >nl> in vexpand docu
|
|
Method Summary
|
Function CNames (InputNames As Variant, NameType As String) As String |
Function Empty () As Variant |
Function GetNameTypes () As Variant |
Function parseCGI (what As String, doc As Variant) As String |
Function Vappend (array As Variant, AppendArray As Variant) As Variant |
Function Vdate (argument As Variant) As Variant |
Function VDelimiters (delChars As String) As Variant |
Function VExpand (Mastertext As String, Replacements As Variant) As String |
Function VExpandOpt (Mastertext As String, Replacements As Variant, opt As String) As String |
Function VExpandPlaceholder (arg As String, Replacements As Variant, Terminates As String, opt As Integer) As Variant |
Function VExpandText (Arg As String, Replacements As Variant, Skip As Integer, Cond As Integer, Opt As Integer) As String |
Function VExplode (Arg As Variant, Delimiter As Variant) As Variant |
Function VFormulaStr (Array As Variant) As Variant |
Function VImplode (Arg As Variant, Delimiter As Variant) As String |
Function VLeft (Array As Variant, Delim As Variant) As Variant |
Function VLeftBack (Array As Variant, Delim As Variant) As Variant |
Function VMatchesPattern (CheckStr As String, Byval PatternSIx As Integer) As Integer |
Function VNames (InputNames As Variant) As String |
Function VRight (Array As Variant, Delim As Variant) As Variant |
Function VRightback (Array As Variant, Delim As Variant) As Variant |
Function VScriptStr (Array As Variant) As Variant |
Function VSort (Arg As Variant) As Variant |
Function Vtrim (array As Variant) As Variant |
Function VTwinSort (Argument As Variant, TwinArgument As Variant) As Variant |
Function VUnique (array As Variant) As Variant |
VExplode
Public Function VExplode(Arg As Variant,Delimiter As Variant) As Variant
Splits the Args into items with regard to the delimiters. Datatypes are preserved. Single
values are always returned as an one element array.
Example
"abc,def;ghi":"jkl;mno" and ",":";" as delimiters would result in the five element array "abc":"def":"ghi":"jkl":"mno"
-
Parameters:
-
| Arg | Variant | array or single value of type string, number, date or EMPTY
|
| Delimiter | Variant | array of strings used toseparate the items.
|
-
Returns:
-
| Variant | the resulting array of splitted items
|
-
See also:
-
-
History:
-
VImplode
Public Function VImplode(Arg As Variant,Delimiter As Variant) As String
Glues the items in Arg into a string, in which the items are separated by delimiters. If delimiter is an array it will use the first element of the delimiters.
Example
"abc":"def":"ghi":"jkl":"mno" and";" as delimiters would result in the string "abc;def;ghi;jkl;mno"
-
Parameters:
-
| Arg | Variant | array or single value of type string, number, date or EMPTY
|
| Delimiter | Variant | containing a string used to separate the items.
|
-
Returns:
-
| Variant | the resulting array of joined, delimited items
|
-
See also:
-
-
History:
-
VDelimiters
Public Function VDelimiters(delChars As String) As Variant
Creates an array of delimiters from the characters in delChars. If the character is
- COMMA, SEMICOLON, SPACE, or any other Character it stands for it's own
- LF ASCII(10) decodes into a Newline as Sepatator, Which in fact is CR+LF
- FF ASCII(12) decodes into an empty line as a separator, which infact is CR+LF+CR+LF
If both FF and LF are used, specify FF first in order to proces the empty lines first.
-
Parameters:
-
| delChars | String | used to create the array of separator.
|
-
Returns:
-
| Variant | the resulting array of splitted items
|
-
See also:
-
-
History:
-
VSort
Public Function VSort(Arg As Variant) As Variant
Sorts the items in the Arg. These items may be of any type that can be compared.
The algorithm curently is a simple bubble sort and is stabile and fastest on sorted arrays
-
Parameters:
-
| Arg | Variant | the array of items to be sorted or EMPTY
|
-
Returns:
-
-
History:
-
VTwinSort
Public Function VTwinSort(Argument As Variant,TwinArgument As Variant) As Variant
Sorts the items in the TwinArgument based upon the corresponding values in the Argument.The items in
Argument may be of any type that can be compared. Both Arrays need to have the same number of elements
except when the TwinArgument is EMPTY. Given the TwinArgument is EMPTY we return the sorted indices.
The algorithm currently is a simple bubble sort is stabile and fastest on sorted Arrrays
-
Parameters:
-
| Argument | Variant | the Arrray of sortkeys Or EMPTY
|
| TwinArgument | Variant | the Arrray of items to be sorted
|
-
Returns:
-
| Variant | the sorted output.
|
-
Errors:
-
| ErrArgDimMismatch | if Arguments have unequal dimensions
|
-
History:
-
VExpandPlaceholder
Private Function VExpandPlaceholder(arg As String,Replacements As Variant,Terminates As String,opt As Integer) As Variant
VExpandText
Private Function VExpandText(Arg As String,Replacements As Variant,Skip As Integer,Cond As Integer,Opt As Integer) As String
VExpandOpt
Public Function VExpandOpt(Mastertext As String,Replacements As Variant,opt As String) As String
This routine is a Generalization of the VExpand, which allows to specify the behaviour in case of invalid
placeholders.
- "KeepUndef" an undefined < placeholder > is not touched
- "EmptyUndef" an undefined < placeholder > is relpaced by ""
- "ErrorOnUndef" an error is generate in case of an undefined < placeholder >
- "" or invalid Default is "ErrorOnUndef"
Interprets the mastertext and replaces the Placeholders with th ereplacements provided. The mastertext
specification follows an easy syntax notation including conditions that are handeled recursively.The syntax
is formally described in the VExpand command.
The function is based on the auxilary routine VExpandText.
-
Parameters:
-
| Mastertext | String | the definition of the format
|
| Replacements | Variant | may be an array of values, a list of values, a notesDocument instance,
or even an instance of an OCard generated class, that provides GetAttribByName.
|
| Opt | string | specification of the behaviour in case of missing replacements See above
|
-
Returns:
-
| String | the expanded mastertext.
|
-
Errors:
-
| ErrIncompleteCondition | if the mastertext can't be interpreted more errors see VExpandText
|
-
See also:
-
-
History:
-
VExpand
Public Function VExpand(Mastertext As String,Replacements As Variant) As String
Interprets the mastertext and replaces the Placeholders with the replacements provided. The mastertext
specification follows an easy syntax notation including conditions that are handeled recursively. It uses the
default error handling in case of undefined placeholders.
This makes it easy to specify the different formats e.g an addresslabel, of a phone number or alike.
The syntax is formally described below using the following notational convention
- [optional]
- {nonterminal}
- alternative | alternative|...
- "literal"
{mastertext}={expression} [ {mastertext} ]
{expression}= {text} | "<"{placeholder} [ ";" {format} ]">" | "<"{basicplace}">" | "["{condition}"]"
{text}= "" or any character except ";" or "[" or "]" or {op}
{op}= ">" | "<" | "=" | "><" | "<>"
{placeholder}= {ix} | {Id} | {attrib}
{basicplace}= "[" | "]" | "SC" | "LF" | "EQ" | "GR" | "LE" | "NE" | "HT" | "NL"
GR we return >
LE we return <
EQ we return =
NE we return <>
SC we return ;
HT we return Horizontal tabulator (Char 9 )
LF we return Line feed (Char 10 ) for use in Dialogs!
NL we return Line feed (Char 0 )
[ or ] we return the corresponding character
{ix} is a number, we return the corresponding array-element of the Replacements,
{Id} is a String, we return the corresponding list-element of the Replacements. If the name is EMPTY we return "". Leading and trailing spaces are ignored.
{attrib} an Instance of a business object we return the coresponding field value.If the name is EMPTY we return "". Leading and trailing spaces are ignored.
If there is no replacement specification is given, we return the attribname itself.
{Format} = {integer} | {fmt}
{fmt} any Lotus script format like > for uppercase, Percent see Lotus Script function Format[$] ( expr [ , fmt ] )
{integer} any positive or negative number which chunks the number into character portions as given by the integer
e.g 1234567890 and format 3 results in 123 456 789 0 while -4 results in 12 3456 7890
{condition} = {operand} [ {Op} {operand} ] ";" {truecase} [";" {falsecase} ]
if the second operand is omitted, we test that the first operand in not EMPTY
{truecase} = {mastertext}
{falsecase}= {mastertext}
{operand} = {placeholder} | text
Example:
Given <PCountry> is 49, <PArea> is 211, <PLine> is 51896, <PExtension> is 99, and the mastertext is
[<PCountry>;+<PCountry> -][<PArea>; (0) <PArea;3> - ]<PLine;3>[<PExtension>; - <PExtension;3>]
the expanded phonenumber would be
+49 (0) 211 - 518 96 - 99
HINT:
Lotus Script interprets the character as a string end. You must not use in a mastertext if this is further modified in Lotus Script.
-
Parameters:
-
| Mastertext | String | the definition of the format
|
| Replacements | Variant | may be an array of values, a list of values, a notesDocument instance,
or even an instance of an OCard generated class, that provides GetAttribByName.
|
-
Returns:
-
| String | the expanded mastertext.
|
-
Errors:
-
| ErrIncompleteCondition | The mastertext can't be fully interpreted, usually a nesting issue
|
| ErrCharAfterCond | A condition is not terminated correctly
|
| ErrCharInPlaceholder | A placeholder is not terminated correctly
|
| ErrListItemDoesNotExist | A placeholder dies not exist
|
| ErrCharAfterOperator1 | The operator is invalid
|
| ErrCharAfterOperator2 | The operator is invalid
|
| ErrCharInTrue | A true case is not terminated correctly
|
| ErrCharInFalse | A false case is not terminated correctly
|
-
See also:
-
-
History:
-
Vappend
Public Function Vappend(array As Variant,AppendArray As Variant) As Variant
Appends the items of the array and the AppendArray into an combined array. If one of the arguments is EMPTY
it is ignored, that does not mean that empy elements are ignored. The Items can be any type such as string, integer
or others. If the parameter is an individual element , e.g a string, it is treated as an array with one element only.
-
Parameters:
-
| Array | Variant | may be EMPTY, an item or an array of items of any type
|
| AppendArray | Variant | may be EMPTY, an item or an array of items of any type
|
-
Returns:
-
| Variant | the items concatenated into an array or EMPTY
|
-
History:
-
VUnique
Public Function VUnique(array As Variant) As Variant
Deletes all duplicates from the input array. The input may be EMPTY, an item or an array of items
of any type as long as the can be compared.
-
Parameters:
-
| Array | Variant | EMPTY, an item or an array of items of any type
|
-
Returns:
-
| Variant | EMPTY or the resulting array of unique elements
|
-
History:
-
Vtrim
Public Function Vtrim(array As Variant) As Variant
Trims all items and deletes all EMPTY items from the input array. The input may be EMPTY, an item or an array of items
of type string.
-
Parameters:
-
| Array | Variant | EMPTY, an item or an array of items of type string
|
-
Returns:
-
| Variant | EMPTY or the resulting array of trimmed elements
|
-
History:
-
Vdate
Public Function Vdate(argument As Variant) As Variant
Validates any argument that can be a date and returns a valid Lotus Script datetime. Argument can be
any of the following
- NotesDateTime,
- Lotus Script DateTime,
- Strings,
- any Numbers (integers, long, Double)
Vdate combines the conversion of both NotesDateTime and Script DatTime into one flexible routine
-
Parameters:
-
| argument | Variant | anything that can be interpreted as a date/time
|
-
Returns:
-
| Variant | a valid Lotus Script DateTime
|
-
Errors:
-
| TypeMissmatch | The input argument can't be interpreted as a valid date
|
-
History:
-
Empty
Public Function Empty As Variant
Creates the value EMPTY, which is missing from the constants in Lotus Script.
-
Returns:
-
| Variant | with the value EMPTY
|
-
History:
-
GetNameTypes
Public Function GetNameTypes As Variant
Provides you with an array with the valid name types as expected by CNAMES. Usually the first
element"ABBREVIATE" is used as a default value. The list includes both the NameTypes as used by the @Names
function as well as the Lotus Script class NotesName.
-
Returns:
-
| Variant | array with the various Name formats
|
-
See also:
-
-
History:
-
VNames
Public Function VNames(InputNames As Variant) As String
Validates a name and convertsit via the NotesName Object in Lotus Script into a canonicalized string.
-
Parameters:
-
-
Returns:
-
| Variant | a string in a canonicalized form
|
-
Errors:
-
| ErrVNamesNothingEntered | Nothing entered
|
| ErrTypeMismatch | if the string is not CANONICALIZABLE (contains no backslashes), an Error is generated
|
-
History:
-
CNames
Public Function CNames(InputNames As Variant,NameType As String) As String
Converts a proper name in inputNames into a string according to the NameType given as a second parameter.
NameTypes are those provided by CNames but also those used by the @Names function, which differs from the
property names of the NotesName object.
HINT:
There are NameTypes, that do not return results as expected like Surname, PRMD, ...
Example
InputName "Martin Musteman/MyComp/DE" and NameType be "abbreviated" results in
"Martin Musterman/MyComp/DE"
-
Parameters:
-
| InputNames | Variant | the
|
| InputType | String | the format code like "CN", "Abbreviate" etc.
|
-
Returns:
-
| String | a new object of class x
|
-
See also:
-
-
History:
-
| 03.APR.1997 | ESc | Inserted header
|
VLeft
Public Function VLeft(Array As Variant,Delim As Variant) As Variant
Returns for each item in an array of strings the portion left of the first occurence of delimiter from left to right.
If the delimiter is a number the begin of the string with this length is returned.
The function is similar to @Left. If the delimiter is not contained in the array , the result is an empty string. Should
the delimiter be an array, the first element is worked with.
-
Parameters:
-
| Array | Variant | the items to be processed
|
| Delim | Variant | the delimiter to be searched for
|
-
Returns:
-
| Variant | array of the left portions of the items in Array
|
-
History:
-
VRight
Public Function VRight(Array As Variant,Delim As Variant) As Variant
Returns for each item in an array of strings the portion right of the first occurence ofdelimiter from left to right.
If the delimiter is a number the portion right of a begin with this length is returned.
The function is similar to @Right. If the delimiter is not contained in the array, the result is an empty string. Should
the delimiter be an array, the first element is worked with.
-
Parameters:
-
| Array | Variant | the items to be processed
|
| Delim | Variant | the delimiter to be searched for
|
-
Returns:
-
| Variant | array of the right portions of the items in Array
|
-
History:
-
VLeftBack
Public Function VLeftBack(Array As Variant,Delim As Variant) As Variant
Returns for each item in an array of strings the portion left of the last occurence of delimiter from left to right.
If the delimiter is a number a portion left of a remaining end of this length is returned.
The function is similar to @LeftBack. If the delimiter is not contained in the array, the result is an EMPTY string. Should
the delimiter be an array, the first element is worked with.
-
Parameters:
-
| Array | Variant | the items to be processed
|
| Delim | Variant | the delimiter to be searched for
|
-
Returns:
-
| Variant | array of the left portions of the items in Array
|
-
History:
-
VRightback
Public Function VRightback(Array As Variant,Delim As Variant) As Variant
Returns for each item in an array of strings the portion right of the last occurence of delimiter from left to right.
If the delimiter is a number the right end of teh string this length is returned.
The function is similar to @RightBack. If the delimiter is not contained in the array, the result is an EMPTY string. Should
the delimiter be an array, the first element is worked with.
-
Parameters:
-
| Array | Variant | the items to be processed
|
| Delim | Variant | the delimiter to be searched for
|
-
Returns:
-
| Variant | array of the right portions of the items in Array
|
-
History:
-
VFormulaStr
Public Function VFormulaStr(Array As Variant) As Variant
Escapes a string or each item of an Array with the sequences needed for @formulas
- \ becomes \\
- ' becomes \'
- and " becomes \" .
-
Parameters:
-
| Array | Variant | the items to be processed
|
-
Returns:
-
| Variant | array of the masked items in Array
|
-
History:
-
VScriptStr
Public Function VScriptStr(Array As Variant) As Variant
Escapes a string or each item of an Array with the sequences needed for Strings in Lotus Script
-
Parameters:
-
| Array | Variant | the items to be processed
|
-
Returns:
-
| Variant | array of the masked items in Array
|
-
History:
-
parseCGI
Public Function parseCGI(what As String,doc As Variant) As String
This function takes a key and doc as parameters, and return the value that represented by
that key. The doc is the sessions document context, which is an in Memory document containing
th einformation as provided with the call of the agent.
Example
Let query_string be key=val & Anotherkey= another%20val & . . .) . Ask for "key" the result will be "val" while
asking for "Anotherkey" will result in "another val".
-
Parameters:
-
| What | String | denoting the value to retrieve
|
| Doc | Variant | which is a NotesDocument Context
|
-
Returns:
-
| String | value as asked for.
|
-
History:
-
| 03.APR.2000 | ESc | Inserted header
|
| 02.MAY.2000 | ESc | Compare the Value Name case and pitch insensitively! Handles %20 as blank
as well as all hexadecimals preceded by %
|
VMatchesPattern
Private Function VMatchesPattern(CheckStr As String,Byval PatternSIx As Integer) As Integer
| Top | LotusScript Doc |
| © Lotus Professional Services |
| generated on : 05-Apr-01 10:01:43 AM |